#pragma once
#include"Common.h"
class ThreadCache
{
public:
	// 申请和释放内存对象
	void* Allocate(size_t size);
	void Deallocate(void* ptr, size_t size);

	// 从thread cache内存块不足时向central cache缓存获取对象
	void* FetchFromCentralCache(size_t index, size_t size);

	//释放对象时，链表太长了，回收内存到中心内存
	void ListTooLong(FreeList& list, size_t size);
private:
	FreeList _freeLists[NFREE_LISTS];
};
//保证threadcache得独立性
static _declspec(thread)ThreadCache* pTLSThreadCache = nullptr;